package com.swd.order.model;



import lombok.Data;
import org.assertj.core.util.Maps;

import java.security.Key;
import java.util.HashMap;
import java.util.Map;

@Data
public class WxNotifyModel {


    private String touser;
    private String template_id;
    private String page;
    private String miniprogram_state;
    private Map<String,Map<String,String>> data;
    private String appid;
    private Map<String,String>  miniprogram;


    public static WxNotifyModel WxNotifyBuild(String touser,String templateId,String page,
                                           String miniprogramState,Map<String,String> map){

        WxNotifyModel wxNotifyModel = new WxNotifyModel();
        wxNotifyModel.setTouser(touser);
        wxNotifyModel.setTemplate_id(templateId);
        wxNotifyModel.setMiniprogram_state(miniprogramState);
        wxNotifyModel.setPage(page);

        Map<String,Map<String,String>> mapList = new HashMap<>();

        map.forEach((key,value)->{
            mapList.put(key, Maps.newHashMap("value",value));
        });
        wxNotifyModel.setData(mapList);

        return wxNotifyModel;
    }

    public static WxNotifyModel WxGZHNotifyBuild(String touser,String templateId,
                                              Map<String,String> map){

        WxNotifyModel wxNotifyModel = new WxNotifyModel();
        wxNotifyModel.setTouser(touser);
        wxNotifyModel.setTemplate_id(templateId);

//        wxNotifyModel.setAppid(appid);
//        Map miniInfo = new HashMap();
//        miniInfo.put("appid",appid);
//        miniInfo.put("page",pagepath);
//        wxNotifyModel.setMiniprogram(miniInfo);

        Map<String,Map<String,String>> mapList = new HashMap<>();

        map.forEach((key,value)->{
            mapList.put(key, Maps.newHashMap("value",value));
        });
        wxNotifyModel.setData(mapList);

        return wxNotifyModel;
    }

    public static WxNotifyModel WxGZHNotifyBuild(String touser,String templateId,
                                                 Map<String,String> map,String appid,String pagepath){

        WxNotifyModel wxNotifyModel = new WxNotifyModel();
        wxNotifyModel.setTouser(touser);
        wxNotifyModel.setTemplate_id(templateId);

        wxNotifyModel.setAppid(appid);
        Map miniInfo = new HashMap();
        miniInfo.put("appid",appid);
        miniInfo.put("pagepath",pagepath);
        wxNotifyModel.setMiniprogram(miniInfo);

        Map<String,Map<String,String>> mapList = new HashMap<>();

        map.forEach((key,value)->{
            mapList.put(key, Maps.newHashMap("value",value));
        });
        wxNotifyModel.setData(mapList);

        return wxNotifyModel;
    }


    public static WxNotifyModel WxNotifyBuild(String touser,String templateId,Map<String,String> map){

        WxNotifyModel wxNotifyModel = new WxNotifyModel();
        wxNotifyModel.setTouser(touser);
        wxNotifyModel.setTemplate_id(templateId);


        Map<String,Map<String,String>> mapList = new HashMap<>();

        map.forEach((key,value)->{
            mapList.put(key, Maps.newHashMap("value",value));
        });
        wxNotifyModel.setData(mapList);

        return wxNotifyModel;
    }

    public static WxNotifyModel WxNotifyBuild(String touser,String templateId,Map<String,String> map,
                                              String page,String miniprogramState){

        WxNotifyModel wxNotifyModel = new WxNotifyModel();
        wxNotifyModel.setTouser(touser);
        wxNotifyModel.setTemplate_id(templateId);
        wxNotifyModel.setPage(page);
        wxNotifyModel.setMiniprogram_state(miniprogramState);

        Map<String,Map<String,String>> mapList = new HashMap<>();

        map.forEach((key,value)->{
            mapList.put(key, Maps.newHashMap("value",value));
        });
        wxNotifyModel.setData(mapList);

        return wxNotifyModel;
    }

}



